package com.haders.service.event;

import com.haders.util.UserContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Service;

@Service
public class OrderService {
    @Autowired
    private ApplicationEventPublisher eventPublisher;

    public void createOrder(String orderId) {
        UserContext.User user = UserContext.getCurrentUser(); 
        System.out.println("创建订单用户：" + user.getUsername());
        
        // 业务逻辑...
        System.out.println("正在创建订单：" + orderId);

        // 发布事件
        eventPublisher.publishEvent(new OrderCreateEvent(this, orderId));
    }
}
